package Bean;


import Snapshot.SnapshotManager;
import Utils.StateUtils;

import java.io.Serializable;
import java.util.ArrayList;

public class MindMap implements Serializable {

    private Integer id;

    private MindMapNode center;

    private ArrayList<MindMapLine> lines = new ArrayList();

    public MindMap(){}

    public MindMap(Integer id){
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public MindMapNode getCenter() {
        return center;
    }

    public void setCenter(MindMapNode center) {
        this.center = center;
    }

    public ArrayList<MindMapLine> getLines() {
        return lines;
    }

    public void setLines(ArrayList lines) {
        this.lines = lines;
    }

    public void createSnapshotOfReback(){
        SnapshotManager.createSnapshotOfReback(this.id,this);
    }

    public void getSnapshotOfReback(){
        MindMapTemp temp = SnapshotManager.getSnapshotOfReback(this.id);
        if(temp!=null) {
            StateUtils.reback(this, temp);
        }
    }

    public boolean getSnapshotOfNext(){
        MindMapTemp temp = SnapshotManager.getSnapshotOfNext(this.id);
        if(temp!=null){
            StateUtils.reback(this,temp);
            return true;
        }
        return false;
    }

}
